<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>首页</title>
    <link rel="stylesheet" type="text/css" href="css/base.css"/>
    <link rel="stylesheet" type="text/css" href="css/index.css"/>
    <link rel="stylesheet" type="text/css" href="css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="css/loaders.min.css"/>
    <link rel="stylesheet" type="text/css" href="css/loading.css"/>
	<link rel="stylesheet" href="/js/plugins/dialog/dialog.css"/>
    <link rel="stylesheet" href="css/swiper.min.css">

    <script src="js/rem.js"></script>
	<script src="/js/jquery/jquery.min.js"></script>
	<script src="/js/bootstrap/js/bootstrap.min.js"></script>
	<script src="/js/plugins/jrender/jrender.js"></script>
	<script src="/js/plugins/dialog/dialog.min.js"></script>
	<script src="/js/common.js"></script>
    <script src="js/others.js"></script>
	<script src="js/swiper.jquery.min.js"></script>
	<script type="text/javascript">
        var currentPage = 1;
        var pages;
        var travels;
		$(function () {
            $(".loading").addClass("loader-chanage")
            $(".loading").fadeOut(300)


            //查询很贵的商品
            $.get("/products/money",function (data) {
                $("#carouselExampleControls").renderValues({list:data},{
                    handle:function (ele,value) {
                        $(ele).attr("href","/shop/detail.html?id=" + value);
                    }
                })
                //注意坑点,这个不用渲染不出来
                $("#travelsCommends>div:first").addClass("active");
            });

			//发送ajax请求获取一周内的商品信息
			$.get("/products/week",{pageSize:6},function (data) {
                console.log(data);
                renderView(data);
                pages=data.pages;
                travels=data.list;
            },"json");

            //窗口滚动
            $(window).scroll(function () {
                if(isEnd()){
                    if(currentPage<pages){
                        currentPage++;
                        $.get("/products/week",{currentPage:currentPage,pageSize:6},function (data) {
                            $.merge(travels,data.list);
                            renderView({list:travels});
                        },"json");
                    }else{
                        $(document).dialog({
                            type:"notice",
                            infoText:"已经到底部了",
                            autoClose:1500,
                            position:"center"
                        });
                    }
                }
            });

        });
        function renderView(data) {
            $(".travels").renderValues(data,{
                handle:function (ele,value) {
                    $(ele).attr("href","/shop/detail.html?id=" + value);
                }
            })
        }
	</script>
</head>
<!--loading页开始-->
<div class="loading">
	<div class="loader">
        <div class="loader-inner pacman">
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
        </div>
	</div>
</div>
<!--loading页结束-->
	<body>		
		<!--头部区域-->
	    <header class="mui-bar mui-bar-nav" id="header">
			<a class="btn" href="/mine/profiles.html">
				<i class="iconfont icon-fanhui"></i>
			</a>
	        <h4>积分商城</h4>
	    </header>
		<div id="main" class="clearfloat warp">			
		    <div class="mui-content">
				<!--banner开始-->
				<div class="banner swiper-container" id="carouselExampleControls">
		            <div class="swiper-wrapper" render-loop="list">
		                <div class="swiper-slide"><a render-key="list.id" render-fun="handle"><img class="swiper-lazy" render-src="list.coverUrl" alt=""></a></div>
		            </div>
		        </div>
		        <!--第一栏分类开始-->
		        <div class="cation clearfloat box-s">
		        	<ul>
		        		<li>
		        			<a href="#">
		        				<img src="./images/ico5.png"/>
		        				<p>新品专区</p>
		        			</a>
		        		</li>
		        		<li>
		        			<a href="#">
		        				<img src="./images/ico2.png"/>
		        				<p>送礼首选</p>
		        			</a>
		        		</li>
		        		<li>
		        			<a href="#">
		        				<img src="./images/ico3.png"/>
		        				<p>积分获取</p>
		        			</a>
		        		</li>
		        		<li>
		        			<a href="#">
		        				<img src="./images/ico4.png"/>
		        				<p>私人定制</p>
		        			</a>
		        		</li>
		        	</ul>
		        </div>
		        <!--第一栏分类结束-->
		        
		      
		        <!--新品专区-->
		        <div class="onnew clearfloat">
		        	<div class="boutit clearfloat">
		        		<span></span>
		        		<samp>新品专区</samp>
		        	</div>
		        	<div class="content clearfloat travels">
		        		<div class="top clearfloat" render-loop="list">
		        			<div class="list clearfloat box-s">
		        				<a render-key="list.id" render-fun="handle">
			        				<div class="clearfloat fl box-s">
			        					<p class="tit text" render-html="list.name"></p>
				        				<p><span>积分:</span><span class="over db red" render-html="list.integral"></span></p>
			        				</div>
			        				<div class="tu clearfloat fr box-s">
			        					<span></span>
			        					<img render-src="list.coverUrl"/>
			        				</div>
		        				</a>
		        			</div>
		        		</div>
		        	</div>
		        </div>

		<!--footer star-->
		<footer class="page-footer fixed-footer" id="footer">
			<ul>
				<li class="active">
					<a href="shop.html">
						<i class="iconfont icon-shouye"></i>
						<p>首页</p>
					</a>
				</li>
				<li>
					<a href="cation.html">
						<i class="iconfont icon-icon04"></i>
						<p>分类</p>
					</a>
				</li>
				<li>
					<a href="shopcar.html">
						<i class="iconfont icon-gouwuche"></i>
						<p>购物车</p>
					</a>
				</li>
				<li>
					<a href="center.html">
						<i class="iconfont icon-yonghuming"></i>
						<p>我的</p>
					</a>
				</li>
			</ul>
		</footer>
		<!--footer end-->
	</body>

</html>